﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ccit.OA.Utils;
using System.Collections.Generic;

namespace Ccit.OA.NewsCenter
{
    public partial class news_search_list : Ccit.Utils.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack){
                _hidTabId.Value =( null != Request.QueryString["TABID"]) ? Request.QueryString["TABID"].ToString(): "";
               // _hidWhereClause.Value = Ccit.OA.Utils.SysInterface.GetPageDataRangeSQL("",_hidTabId.Value);

                //快捷查询
                _hidFastClause.Value = (null!=Request.QueryString["fastClause"]) ? Request.QueryString["fastClause"].ToString() : "";
                //树传来的栏目类型主键
                _hidColumnId.Value = (null != Request.QueryString["columnId"]) ? Request.QueryString["columnId"].ToString() : "";
                _hidType.Value = (null != Request.QueryString["Type"]) ? Request.QueryString["Type"].ToString() : "0";
            }
            initializePage();
        }
        private void initializePage()
        {
            SubmitBLL oSubmit = new SubmitBLL();
            string sFastClause = _hidFastClause.Value;
            //根据NEWS_A8_10=sFastClause ，查询NEWS_A8_50
            string sClauseXml="";
            if (Session["QryClause"] != null)
            {
               sClauseXml = Session["QryClause"].ToString();
               Session.Remove("QryClause");
            }
            else
              sClauseXml = SysInterface.GetNameStrByIdStr("NEWS_A8", "NEWS_A8_10", "NEWS_A8_50", sFastClause, "");
            MsClauseAttr msClauseAttr = new MsClauseAttr(sClauseXml);
            List<MsNews> lstNews = oSubmit.GetNewsByClause(msClauseAttr, _hidColumnId.Value,_hidType.Value);
            gvNews.DataSource = lstNews;
            gvNews.DataBind();
        }

        protected void gvNews_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
        {
            if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return;
            string sNewsStatus = gvNews.GetRowValues(e.VisibleIndex, "NewsStatus").ToString();
            string spicFlag = gvNews.GetRowValues(e.VisibleIndex, "PicFlag").ToString();
            string sTopSign = gvNews.GetRowValues(e.VisibleIndex, "TopFlag").ToString();
            string issueUserId = gvNews.GetRowValues(e.VisibleIndex, "IssueUserId").ToString();
            string ColumnNo = gvNews.GetRowValues(e.VisibleIndex, "ColumnNo").ToString();
            //信息栏目
            ColumnBLL columnbll = new ColumnBLL();
            string colName =( columnbll.GetMsColumnObj(ColumnNo).columnName != "") ? columnbll.GetMsColumnObj(ColumnNo).columnName : "&nbsp";           
            e.Row.Cells[1].Text = colName;
            //信息状态
            if (sNewsStatus == "0")
                e.Row.Cells[2].Text = "未提交";
            else if (sNewsStatus == "1")
                e.Row.Cells[2].Text = "已提交";
            else if (sNewsStatus == "2")
                e.Row.Cells[2].Text = "已发布";
            //图片标志
            if (spicFlag == "0")  
                e.Row.Cells[3].Text="否";
            else
                e.Row.Cells[3].Text="是";
            //置顶标志
            if (sTopSign == "0")
                e.Row.Cells[4].Text = "否";
            else
                e.Row.Cells[4].Text = "是";
            //用户名
            string userName = SysInterface.GetNameStrByIdStr("SYS_A1", "SYS_A1_10", "SYS_A1_40", issueUserId, ""); 
            e.Row.Cells[7].Text=userName;
        }
    }
}
